Skip to content

Reject out-of-range UTC offsets in the pure-Python parsers - #1015

Open
Sharadhi-v98 wants to merge 2 commits into
python-pendulum:masterfrom
Sharadhi-v98:parser-reject-oversized-offset
Open

Sharadhi-v98 wants to merge 2 commits into
python-pendulum:masterfrom
Sharadhi-v98:parser-reject-oversized-offset

Conversation

@Sharadhi-v98

Copy link
Copy Markdown
  1. The ISO 8601 parser (parse_iso8601) and from_format both build a timezone offset from the parsed hour and minute without bounding its magnitude, so an offset like +99:59 is accepted.
  2. That yields a FixedTimezone whose utcoffset sits far outside the plus/minus 24h datetime permits, and the returned value raises the moment it is used (isoformat, astimezone, comparison across zones).

Added an upper bound in both callees, matching the Rust parser which already rejects offsets above 24 hours.

  • Added tests for changed code.
  • Updated documentation for changed code.

Comment thread src/pendulum/formatting/formatter.py Outdated
Comment thread src/pendulum/parsing/iso8601.py Outdated
Signed-off-by: Sharadhi V <sharadhi@labs.digiscrypt.com>
@Sharadhi-v98

Copy link
Copy Markdown
Author

any update?

@codspeed

codspeed Bot commented Oct 9, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 1 untouched benchmark


Comparing Sharadhi-v98:parser-reject-oversized-offset (33843aa) with master (d3f44aa)

Open in CodSpeed

@ashb

ashb commented Oct 9, 2026

Copy link
Copy Markdown
Member

@Sharadhi-v98 Just run tests, you've got some test failures to look at please.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants